const SERVICE = require("../../lib/js/service.js");

Page({
  data:{
    textareaPlaceholder_val: "",    // 文本区域提示
    textarea_val: "",   // 文本区域
  },
  onLoad(options){
    wx.setNavigationBarTitle({
      title: options.title
    })
    this.setData({
      textareaPlaceholder_val: options.title,
      textarea_val: options.info,
    });
    
  },

  /*分享*/ 
  onShareAppMessage(){},
  
  /*页面卸载*/
  onUnload(){
    let td = this.data;
    if (td.textareaPlaceholder_val == "公司介绍"){
      this.compileInfo({ 
        thirdCookie: wx.getStorageSync("thirdCookie"),
        describe: td.textarea_val
      });
    } else if (td.textareaPlaceholder_val == "一句话介绍"){
      this.compileInfo({
        thirdCookie: wx.getStorageSync("thirdCookie"),
        intro: td.textarea_val
      });
    }
  },
   
  /*字体*/ 
  getTextarea(e){
    this.setData({
      textarea_val:e.detail.value
    });
  },

  /*编辑信息*/
  compileInfo(params) {
    wx.showLoading({
      title: "编辑中...",
      mask: true
    });
    SERVICE.POST(SERVICE.URL.myCompany, params, (status, res) => {
      console.log("编辑信息:", res);
      wx.hideLoading();
      if (res.data.status != "success") {
        wx.showToast({
          title: "编辑失败",
          icon: "none",
          mask: true
        });
      }
    });
  },
});
